package com.cloud.file.service.impl;

import com.cloud.file.mapper.FileInfoMapper;
import com.cloud.file.service.FileInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @packageName: com.cloud.file.service.impl
 * @name: FileInfoServiceImpl
 * @description:
 * @author: 董定卓
 * @dateTime: 2019/7/16 11:54
 */
@Service
public class FileInfoServiceImpl implements FileInfoService {

    @Autowired
    FileInfoMapper mapper;

    /**
     * 添加文件信息
     *
     * @param map
     * @return
     */
    @Override
    public int addFileInfo(Map<String, Object> map) {
        return mapper.insert(map);
    }

    /**
     * 更新文件信息
     *
     * @param map
     * @return
     */
    @Override
    public int updateFileInfo(Map<String, Object> map) {
        return mapper.update(map);
    }

    /**
     * 文件信息分页列表
     *
     * @param map
     * @param pageSize
     * @param pageNo
     * @return
     */
    @Override
    public List<Map<String, Object>> pagination(Map<String, Object> map, int pageSize, int pageNo) {
        map.put("start", (pageNo - 1) * pageSize);
        map.put("num", pageSize);
        return mapper.list(map);
    }

    /**
     * 文件信息分页列表统计
     *
     * @param map
     * @return
     */
    @Override
    public long count(Map<String, Object> map) {
        return mapper.count(map);
    }

    /**
     * 根据mad5获取文件信息
     *
     * @param map
     * @return
     */
    @Override
    public Map<String, Object> getFileInfo(Map<String, Object> map) {
        return mapper.get(map);
    }
}
